package com.yan.demo;

import java.lang.module.FindException;

public class MethodTest4 {
    public static void main(String[] args) {
        int[] arr = {1, 3, 5, 7, 9, 1,0, 1, 5,6,2,3};
        int[] arr1 = new int[arr.length];
       arrCopy(arr);
    }

    public static void arrCopy(int[] arr){
        int k = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1; j < arr.length; j++) {
                if(arr[i] == arr[j]){
                    arr[j] = -1;
                }
            }
        }
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] == -1){
                count++;
            }
        }
        int[] newArr = new int[arr.length - count];
        int index = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] != -1){
                newArr[index] = arr[i];
                index++;
            } else {
               continue;
            }
            if(index == newArr.length){
                break;
            }
        }
        for (int i = 0; i < newArr.length; i++) {
            System.out.print(newArr[i] + " ");
        }
    }
}
